# -*- python -*-
#:kivy 1.7
#   :import sla kivy.adapters.simplelistadapter
#:import sla kivy.adapters.listadapter
#:import tdisplay levin.tastingDisplay
#:import guiCommon levin.guiCommon

<TastingEntryWid>:
    orientation: 'horizontal'
    height: max(_value.height, _att.height)
    size_hint: 1, None
    CompactLabel:
        id: _att
        text: root.attr
        
    Label:
        id:_value
        text_size: self.width, None
        height: self.texture_size[1] 
        text: root.value
        multiline: True
        size_hint: 1, None

<TastingWidget2>:
    orientation: 'vertical'
    size_hint: 1,None
    height: sum(c.height for c in self.children)*1.2
    padding: 2

    canvas.after:
        Clear
        Color:
            rgba: [0.533, 0.035, 0.024, .2] if self.is_selected else [0, 0, 0 , .0]
        Rectangle:
            pos: self.pos
            size: self.size

    

<TastingTreeViewNode>:
    color_selected: [0.533, 0.035, 0.024, .2]

<TastingWidgetButtons>:
    size_hint: 1, None
    height: _b1.height 
    LeVinButton:
        id: _b1
        text: _("Details") if (root.parent and root.parent.basicMode) else _("Basics")
        on_press: root.parent.advancedClicked()
    LeVinButton:
        text: "Edit"
        on_press: guiCommon.commonEvents.dispatch('on_start_edit_tasting', root.parent.tasting)
    LeVinButton:
        text: "Suppress"
        on_press: guiCommon.commonEvents.dispatch('on_delete_tasting', root.parent.tasting)
    

<TastingDisplay>:
    tastingList: _tastingList
    buttonBar: _buttonBar
    orientation: 'vertical'
    height: _tastingList.height + _buttonBar.height
    TListView:
        id: _tastingList
    BoxLayout:
        id: _buttonBar
        size_hint: (1,None)
        height: max( [w.height for w in self.children]+[0])
        LeVinButton:
            id: editB
            size_hint: (1,None)            
            text: _('Add tasting')
            icon_src: 'icons/addBottle.png'
            on_press: guiCommon.commonEvents.dispatch('on_start_edit_tasting',root.bottle)

<TListView>:
    adapter: _lv.adapter
    ListView:
        id: _lv
        adapter:
            sla.ListAdapter(
            data=[],
            cls=tdisplay.TastingWidget2,
            args_converter=tdisplay.args_converter_default,
            propagate_selection_to_data=False
            )
